/*
 * Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#define NDEF_HEADER_SIZE 0x2 // NDEF协议的头部大小

#define NDEF_PROTOCOL_HEADER_OFFSET 0           // NDEF协议头(固定)
#define NDEF_PROTOCOL_LENGTH_OFFSET 1           // NDEF协议数据的总长度位
#define NDEF_PROTOCOL_MEG_CONFIG_OFFSET 2       // 标签的控制字节位
#define NDEF_PROTOCOL_DATA_TYPE_LENGTH_OFFSET 3 // 标签数据类型的长度位
#define NDEF_PROTOCOL_DATA_LENGTH_OFFSET 4      // 标签的数据长度位
#define NDEF_PROTOCOL_DATA_TYPE_OFFSET 6        // 标签的数据类型位
#define NDEF_PROTOCOL_VALID_DATA_OFFSET 20      // 有效数据位
#define NDEF_PROTOCOL_TYPE_OFFSET      5        // 类型数据

#define NDEF_PROTOCOL_ID_LENGTH_OFFSET 5      // 标签的数据长度位

#define NDEF_PROTOCOL_DATA_LENGTH_OFFSET2 5 // 标签数据类型的长度位
#define NDEF_PROTOCOL_DATA_LENGTH_OFFSET3 6 // 标签数据类型的长度位
#define NDEF_PROTOCOL_DATA_LENGTH_OFFSET4 7 // 标签数据类型的长度位

#define NDEF_PROTOCOL_PAYLOAD_HEAD_SIZE   3
#define NDEF_PROTOCOL_HEAD_SIZE           4
#define NFC_PAGE_SIZE 16 // NFC每页的字节数

extern uint8_t *nfcBuf;

int readNfc(void);
int i2cInit(void);
int writeNfc(uint8_t *data);
